﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace Gmantis.Controls
{
    public class SideThicknessConverter : IValueConverter
    {
        object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Thickness thickness = (Thickness)value;
            List<string> list = new List<string>(((string)parameter).ToLower().Split(new char[] { '-' }));
            double num = 1.0;
            foreach (string str in list)
            {
                if (str.StartsWith("ratio:"))
                {
                    num = double.Parse(str.Substring(6), CultureInfo.InvariantCulture);
                }
            }
            if (list.Contains("negate"))
            {
                num = -num;
            }
            return new Thickness(list.ContainsAny<string>(new string[] { "left", "all" }) ? (thickness.Left * num) : 0.0, list.ContainsAny<string>(new string[] { "top", "all" }) ? (thickness.Top * num) : 0.0, list.ContainsAny<string>(new string[] { "right", "all" }) ? (thickness.Right * num) : 0.0, list.ContainsAny<string>(new string[] { "bottom", "all" }) ? (thickness.Bottom * num) : 0.0);
        }

        object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
